<template>
  <div class="hot">
    <div class="content-wrapper">
      <!-- 创作中心 -->
      <div class="creation-center">
        <h2>创作中心</h2>
        <div class="creation-stats">
          <div class="stat-item">
            <span class="number">0</span>
            <span class="label">提问</span>
          </div>
          <div class="stat-item">
            <span class="number">0</span>
            <span class="label">回答</span>
          </div>
          <div class="stat-item">
            <span class="number">0</span>
            <span class="label">文章</span>
          </div>
        </div>
      </div>

      <!-- 热门话题 -->
      <div class="hot-topics">
        <h2>热门话题</h2>
        <div class="topic-list">
          <div class="topic-item" v-for="i in 5" :key="i">
            <span class="topic-name">热门话题 {{ i }}</span>
            <span class="topic-count">{{ 1000 + i * 100 }} 讨论</span>
          </div>
        </div>
      </div>

      <!-- 问题列表 -->
      <QuestionList :questions="questions" :loading="loading" />
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { useQuestionStore } from '@/stores/question'
import QuestionList from '@/components/QuestionList.vue'

const questionStore = useQuestionStore()
const questions = ref([])
const loading = ref(true)

const fetchQuestions = async () => {
  loading.value = true
  try {
    await questionStore.fetchRecommendQuestions()
    questions.value = questionStore.getRecommendQuestions
  } catch (error) {
    console.error('Failed to fetch questions:', error)
  } finally {
    loading.value = false
  }
}

onMounted(() => {
  fetchQuestions()
})
</script>

<style scoped lang="scss">
.hot {
  padding: 20px;
  max-width: 1000px;
  margin: 0 auto;

  .content-wrapper {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(18, 18, 18, 0.1);
  }

  .creation-center {
    padding: 20px;
    border-bottom: 1px solid #f0f0f0;

    h2 {
      margin: 0 0 20px;
      font-size: 18px;
      font-weight: 600;
      color: #121212;
    }

    .creation-stats {
      display: flex;
      gap: 40px;

      .stat-item {
        display: flex;
        flex-direction: column;
        align-items: center;

        .number {
          font-size: 24px;
          font-weight: 600;
          color: #121212;
        }

        .label {
          margin-top: 4px;
          font-size: 14px;
          color: #8590a6;
        }
      }
    }
  }

  .hot-topics {
    padding: 20px;
    border-bottom: 1px solid #f0f0f0;

    h2 {
      margin: 0 0 20px;
      font-size: 18px;
      font-weight: 600;
      color: #121212;
    }

    .topic-list {
      .topic-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 0;
        border-bottom: 1px solid #f0f0f0;

        &:last-child {
          border-bottom: none;
        }

        .topic-name {
          font-size: 14px;
          color: #121212;
        }

        .topic-count {
          font-size: 12px;
          color: #8590a6;
        }
      }
    }
  }
}
</style> 